#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
    int l,r;
}yi[100001];
int id;
int l[100001],r[100001],qzh[1000001];
bool c[1000001],chao[100001];
bool cmp(node a,node b){
    if(a.l != b.l) return a.l < b.l;
    return a.r < b.r;
}
signed main(){
    freopen("detect.in","r",stdin);freopen("detect.out","w",stdout);
    int t;cin >> t;
    while(t--){
        memset(l,0,sizeof(l));memset(r,0,sizeof(r));memset(qzh,0,sizeof(qzh));memset(c,0,sizeof(c));memset(chao,0,sizeof(chao));
        int n,m,L,V,cnt = 0;cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i++){
            int d,v,a;scanf("%lld %lld %lld",&d,&v,&a);
            if(a == 0){
                if(v > V) l[i] = d,r[i] = L;
                else l[i] = -1,r[i] = -1;
                continue;
            }
            double s = (V*V-v*v)*1.0/(2*a);
            if(a > 0){
                if(v > V) l[i] = d,r[i] = L;
                else if(v == V) l[i] = d + 1,r[i] = L;
                else l[i] = floor(d + s + 1),r[i] = L;
            }
            else if(a < 0){
                if(v <= V) l[i] = -1,r[i] = -1;
                else l[i] = d,r[i] = min(L,(int)ceil(d + s - 1));
            }
            if(l[i] > r[i]) l[i] = -1,r[i] = -1;
            //cout << l[i] << " " << r[i] << endl;
        }
        for(int i = 1;i <= m;i++){
            int p;scanf("%lld",&p);c[p] = 1;
        }
        for(int i = 1;i <= L;i++) qzh[i] = qzh[i-1] + c[i];
        for(int i = 1;i <= n;i++){
            assert(l[i] >= -1 && r[i] >= -1 && l[i] <= L && r[i] <= L);
            if(l[i] <= 0 || r[i] <= 0) continue;
            if(qzh[r[i]] > qzh[l[i]-1]){
                chao[i] = 1,cnt++;
                yi[++id].l = qzh[l[i]-1] + 1;yi[id].r = qzh[l[i]-1];
                //cout << i << endl;
            }
        }
        cout << cnt << " ";
        sort(yi + 1,yi + id + 1,cmp);
        int save = -1,cnt2 = 0;
        for(int i = 1;i <= id;i++){
            if(yi[i].l <= save && yi[i].r >= save) continue;
            else save = yi[i].r,cnt2++;
        }
        cout << cnt2 << endl;
    }
    return 0;
}
/*
1
5 2 15 3
5 1 -1
9 4 -1
10 3 -1
11 9 -20
1 4 -4
1 12
*/
